﻿<%@ WebHandler Language="C#" Class="SynchronizeUser" %>

using System;
using System.Web;

/// <summary>
/// 用户和单位信息同步
/// </summary>
public class SynchronizeUser : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        String versionID = context.Request["versionId"];
        
         string strReturn = synchronous(versionID);
         context.Response.Write(strReturn);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    /// <summary>
    /// 用户和单位信息同步
    /// </summary>
    /// <param name="versionId">版本号</param>
    /// <returns></returns>
    public string synchronous(String versionId)
    {
//        string strXml = @"<?xml version='1.0' encoding='UTF-8'?>
//<operationXml><trans><versionId>8a8a93b05a41b2cf015a449cefbd0220</versionId><transType>ADD_USER</transType><transXml><id>8a8a93b05a41b2cf015a449cefbd021d</id><userId>syn_lbx0723d021f</userId><appId>4028fb83507dd41701507dd614ec0003</appId><display>0</display><username>syn_lbx0723d021f</username><pwd>8a8a93b05a41b2cf015a449cefbd021e</pwd><organId>O0000000000000009489</organId><organCode>8a8a93b157c195da0157d61f1dfc0e52</organCode><struId>S0000000000000021377</struId><struPath>rootId#1#S0000000000000000424#S0000000000000021377</struPath><parentOrganId>O0000000000000000436</parentOrganId><parentOrganCode>0000000000110100000000466000000000002</parentOrganCode><name>李保学</name><organ_mobile>13253950986</organ_mobile><organ_email>lbx0723@163.com</organ_email><zjlx>0</zjlx><zjhm>41122219710314601X</zjhm><rid></rid><unitname>义马豫西地质工程有限公司</unitname><unitbsdtid>C1C6C9D705AE4C63B82741998F691E77</unitbsdtid><zzjgdm>59763104X</zzjgdm><surveyleveltype>2</surveyleveltype><tyshxydm>9141128159763104X6</tyshxydm><prefecture>411200</prefecture><sfdlxxqy></sfdlxxqy></transXml></trans></operationXml>";
        
        //string strReturn = "0";
        string strReturn = "{\"message\":\"无法开通行政许可审批事项\",\"type\":\"0\"}";
        try
        {
            ChBusiness.InterfaceClass.UserTbOperation cuiTemp = new ChBusiness.InterfaceClass.UserTbOperation();
            SynchronizeClient SC = new SynchronizeClient(System.Configuration.ConfigurationManager.AppSettings["userSynAddress"]);
            string strXml = SC.getTransXmlByVersionId("get_syn", versionId);
            //Common.Log.LogManage.addLogErr(versionId, strXml);
            cuiTemp.AnalyseXml(strXml, "综合服务门户");
            //strReturn = "1";
            strReturn = "{\"message\":\"\",\"type\":\"1\"}"; 
        }
        catch(Exception ex)
        {
            Common.Log.LogManage.addLogErr(versionId, ex.Message);
        }
        return strReturn;
    }


}